package com.aaa.doctor.controller.api;

import com.aaa.doctor.service.CareHistoryService;
import com.aaa.entity.CareHistory;
import com.aaa.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/doctor/api/caseHistory")
public class ApiCaseHistoryController {

    @Autowired
    private CareHistoryService careHistoryService;

    /**
     * 根据patientId查询就诊信息 -- 三表联查
     * @param patientId
     * @return
     */
    @GetMapping("/getCareHistoryByPatientId/{patientId}")
    public Result<List<CareHistory>> getCareHistoryByPatientId(@PathVariable String patientId){
        return careHistoryService.getCareHistoryByPatientId(patientId);
    }

    /**
     * 根据挂号单ID查询对应的病历信息
     * @param registrationId
     * @return
     */
    @GetMapping("/getCareHistoryByRegId/{registrationId}")
    public Result<List<CareHistory>> getCareHistoryByRegId(@PathVariable String registrationId){
        return careHistoryService.getCareHistoryByRegId(registrationId);
    }

    /**
     * 新开就诊 --->  保存病例
     * @param regId
     * @param careHistory
     * @return
     */
    @PostMapping("/saveCareHistory/{regId}")
    public Result<CareHistory> saveCareHistory(@PathVariable String regId,@RequestBody CareHistory careHistory){
        return careHistoryService.saveCareHistory(regId,careHistory);
    }

}
